package com.chenyue.cm.api.user;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import com.chenyue.cm.account.service.JdAccountService;
import com.chenyue.cm.auth.Login;
import com.chenyue.cm.auth.LoginUser;
import com.chenyue.cm.bean.Success;
import com.chenyue.cm.common.constant.DomainConfig;
import com.chenyue.cm.common.constant.ErrorCode;
import com.chenyue.cm.common.utils.StringUtil;
import com.chenyue.cm.common.vo.Page;
import com.chenyue.cm.live.domain.JdLiveViewRecord;
import com.chenyue.cm.live.im.service.ImService;
import com.chenyue.cm.live.service.JdLiveRecordService;
import com.chenyue.cm.live.service.JdLiveService;
import com.chenyue.cm.live.service.JdLiveViewRecordService;
import com.chenyue.cm.match.domain.*;
import com.chenyue.cm.match.service.*;
import com.chenyue.cm.match.vo.MyMatchVo;
import com.chenyue.cm.news.domain.JdNews;
import com.chenyue.cm.news.service.JdNewsService;
import com.chenyue.cm.order.domain.JdOrder;
import com.chenyue.cm.payment.service.JdOrderService;
import com.chenyue.cm.user.domain.*;
import com.chenyue.cm.user.domain.vo.LoginInfo;
import com.chenyue.cm.user.domain.vo.OwnInfoUser;
import com.chenyue.cm.user.domain.vo.UserCollection;
import com.chenyue.cm.user.service.*;
import com.chenyue.cm.user.vo.UserRelation;
import com.chenyue.cm.utils.DateUtils;
import com.chenyue.cm.utils.RedisUtils;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSort;
import io.swagger.annotations.*;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author libingxing
 */
@Api(value = "APP '我的' 模块接口", tags = "用户个人信息相关接口")
@ApiSort(2)
@RestController
@RequestMapping("/api/user")
public class ApiUserController {

    private final JdVerifyService verifyService;

    private final RedisUtils redisUtils;

    private final MyMatchService matchService;

    private final ViewMatchScoreRecordService viewMatchScoreRecordService;

    private final JdAppUserService userService;

    private final JdLiveViewRecordService liveViewRecordService;

    private final JdAccountService accountService;

    private final JdUserRelationService userRelationService;

    private final JdUserCollectionService userCollectionService;

    private final JdNewsService newsService;

    private final JdLiveService liveService;

    private final JdLiveRecordService liveRecordService;

    private final FormatLiveRecordService formatLiveRecordService;

    private final JdLabelSendService labelSendService;

    private final JdUserInviteService userInviteService;

    private final ViewInviteUserService viewInviteUserService;

    private final JdMatchFormatMemberService matchFormatMemberService;

    private final JdOrderService orderService;

    private final JdMatchLiveUserService matchLiveUserService;

    private final ImService imService;

    public ApiUserController(JdVerifyService verifyService, RedisUtils redisUtils, MyMatchService matchService, ViewMatchScoreRecordService viewMatchScoreRecordService, JdAppUserService userService, JdLiveViewRecordService liveViewRecordService, JdAccountService accountService, JdUserRelationService userRelationService, JdUserCollectionService userCollectionService, JdNewsService newsService, JdLiveService liveService, JdLiveRecordService liveRecordService, FormatLiveRecordService formatLiveRecordService, JdLabelSendService labelSendService, JdUserInviteService userInviteService, ViewInviteUserService viewInviteUserService, JdMatchFormatMemberService matchFormatMemberService, JdOrderService orderService, JdMatchLiveUserService matchLiveUserService, ImService imService) {
        this.verifyService = verifyService;
        this.redisUtils = redisUtils;
        this.matchService = matchService;
        this.viewMatchScoreRecordService = viewMatchScoreRecordService;
        this.userService = userService;
        this.liveViewRecordService = liveViewRecordService;
        this.accountService = accountService;
        this.userRelationService = userRelationService;
        this.userCollectionService = userCollectionService;
        this.newsService = newsService;
        this.liveService = liveService;
        this.liveRecordService = liveRecordService;
        this.formatLiveRecordService = formatLiveRecordService;
        this.labelSendService = labelSendService;
        this.userInviteService = userInviteService;
        this.viewInviteUserService = viewInviteUserService;
        this.matchFormatMemberService = matchFormatMemberService;
        this.orderService = orderService;
        this.matchLiveUserService = matchLiveUserService;
        this.imService = imService;
    }

    @Login
    @PostMapping("/editUser")
    @ApiOperation(value = "APP用户信息编辑", notes = "APP用户信息编辑")
    public Success<Object> editUser(
            @ApiIgnore @LoginUser JdAppUser user,
            @ApiParam @RequestBody JdAppUser modifyUser
    ) {
        final LambdaUpdateWrapper<JdAppUser> wrapper = new LambdaUpdateWrapper<>();
        if (modifyUser.getWxUnionId() != null) {
            wrapper.set(JdAppUser::getWxUnionId, modifyUser.getWxUnionId());
        }
        if (modifyUser.getQqUnionId() != null) {
            wrapper.set(JdAppUser::getQqUnionId, modifyUser.getQqUnionId());
        }
        if (modifyUser.getSpeciality() != null) {
            wrapper.set(JdAppUser::getSpeciality, modifyUser.getSpeciality());
        }
        if (modifyUser.getSignature() != null) {
            wrapper.set(JdAppUser::getSignature, modifyUser.getSignature());
        }
        if (modifyUser.getAge() == null) {
            wrapper.set(JdAppUser::getAge, modifyUser.getAge());
        }
        if (StringUtils.isNotBlank(modifyUser.getQqUnionId())) {
            final JdAppUser one = userService.lambdaQuery().eq(JdAppUser::getQqUnionId, modifyUser.getQqUnionId()).one();
            if (one != null) {
                return Success.error(ErrorCode.QQ_HAS_BEEN_BIND.getMsg());
            }
        }
        if (StringUtils.isNotBlank(modifyUser.getWxUnionId())) {
            final JdAppUser one = userService.lambdaQuery().eq(JdAppUser::getWxUnionId, modifyUser.getWxUnionId()).one();
            if (one != null) {
                return Success.error(ErrorCode.WX_HAS_BEEN_BIND.getMsg());
            }
        }
        modifyUser.setId(user.getId());
        wrapper.eq(JdAppUser::getId, user.getId());
        boolean update = userService.update(modifyUser, wrapper);
        try {
            imService.setProfile(modifyUser);
        } catch (Exception ignore) {
        }
        if (update) {
            final JdAppUser newUser = userService.selectByPrimaryKey(user.getId() + "");
            redisUtils.updateUser(newUser);
            return Success.success();
        } else {
            return Success.error(ErrorCode.UPDATE_ERROR.getMsg());
        }
    }

    @Login
    @GetMapping("/ownInfo")
    @ApiOperation(value = "用户个人信息", notes = "用户个人信息")
    @ApiOperationSupport(order = 2)
    public Success<OwnInfoUser> ownInfo(
            @ApiIgnore @LoginUser JdAppUser user
    ) {
        OwnInfoUser result = new OwnInfoUser();
        result.setRelationCount(userRelationService.getRelationCount(Integer.valueOf(user.getId())));
        result.setFansCount(userRelationService.getFansCount(Integer.valueOf(user.getId())));
        result.setAccount(accountService.getAccount(Integer.valueOf(user.getId())));
        result.setCollectCount(userCollectionService.getCollectCount(Integer.valueOf(user.getId())));
        result.setUser(user);
        result.setVerify(verifyService.getVerifyInfo(Integer.valueOf(user.getId())));
        final List<JdLabelSend> labels = labelSendService.list(new LambdaQueryWrapper<JdLabelSend>().eq(JdLabelSend::getGetUser, user.getId()));
        final List<String> labelString = labels.stream().map(JdLabelSend::getLabel).collect(Collectors.toList());
        result.setLabel(labelString);
        final LoginInfo loginInfo = userService.getLoginInfo(Integer.valueOf(user.getId()));
        loginInfo.setIsAnchor(liveService.isAnchor(Integer.valueOf(user.getId())));
        result.setLoginInfo(loginInfo);
        return Success.success(result);
    }

    @Login
    @GetMapping("/verifyInfo")
    @ApiOperation(value = "用户实名信息", notes = "用户实名信息")
    @ApiOperationSupport(order = 3)
    public Success<JdVerify> verifyInfo(
            @ApiIgnore @LoginUser JdAppUser user
    ) {
        return Success.success(verifyService.getVerifyInfo(Integer.valueOf(user.getId())));
    }

    @Login
    @GetMapping("/clearViewRecord")
    @ApiOperation("清除观看记录")
    @ApiOperationSupport(order = 3)
    public Success<Object> clearViewRecord(
            @ApiIgnore @LoginUser JdAppUser user
    ) {
        liveViewRecordService.remove(
                new LambdaQueryWrapper<JdLiveViewRecord>()
                        .eq(JdLiveViewRecord::getUserId, user.getId())
                        .eq(JdLiveViewRecord::getIsConcat, 0)
        );
        return Success.success();
    }

    @Login
    @GetMapping("/viewRecord")
    @ApiOperation("观看记录")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "页数", name = "page", dataType = "string", required = true),
            @ApiImplicitParam(value = "条数", name = "rows", dataType = "string", required = true),
    })
    public Success<Page<List<FormatLiveRecord>>> viewRecord(
            @RequestParam(defaultValue = "1") Integer page,
            @RequestParam(defaultValue = "10") Integer rows,
            @ApiIgnore @LoginUser JdAppUser user
    ) {
        LambdaQueryWrapper<JdLiveViewRecord> eq = new QueryWrapper<JdLiveViewRecord>().lambda()
                .eq(JdLiveViewRecord::getUserId, user.getId())
                .eq(JdLiveViewRecord::getIsConcat, 0)
                .groupBy(JdLiveViewRecord::getLiveRecordId);
        List<JdLiveViewRecord> total = liveViewRecordService.list(eq);
        int count = total.size();
        Page<List<FormatLiveRecord>> result = new Page<>(page, rows, count);
        eq.orderByDesc(JdLiveViewRecord::getCt);
        List<JdLiveViewRecord> list = liveViewRecordService.list(eq.last(result.convertPage()));
        List<Integer> collect = list.stream().map(JdLiveViewRecord::getLiveRecordId).collect(Collectors.toList());
        if (collect.size() > 0) {
//            回放
            List<FormatLiveRecord> recordList = formatLiveRecordService.list(
                    new QueryWrapper<FormatLiveRecord>().lambda()
                            .in(FormatLiveRecord::getId, collect)
            );
            result.setContent(recordList);
        } else {
            result.setContent(new ArrayList<>());
        }

        return Success.success(result);
    }

    @Login
    @GetMapping("/myCollection")
    @ApiOperation("我的收藏")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "当前页", name = "page", dataType = "int", required = true),
            @ApiImplicitParam(value = "条数", name = "rows", dataType = "int", required = true),
            @ApiImplicitParam(value = "类型1回放2新闻", name = "type", dataType = "int", required = true),
    })
    public Success<UserCollection> myCollection(
            @RequestParam(defaultValue = "1") Integer type,
            @RequestParam(defaultValue = "1") Integer page,
            @RequestParam(defaultValue = "10") Integer rows,
            @ApiIgnore @LoginUser JdAppUser user
    ) {
        final UserCollection userCollection = new UserCollection();
        LambdaQueryWrapper<JdUserCollection> eq = new QueryWrapper<JdUserCollection>().lambda()
                .eq(JdUserCollection::getColType, type)
                .eq(JdUserCollection::getUserId, user.getId());
        int count = userCollectionService.count(eq);
        final Page<Object> objectPage = new Page<>(page, rows, count);
        List<JdUserCollection> list = userCollectionService.list(eq.last(objectPage.convertPage()));
        List<Integer> collect = list.stream().map(JdUserCollection::getColId).collect(Collectors.toList());
        if (collect.size() > 0) {
            if (type == 1) {
//            回放
                Page<List<FormatLiveRecord>> result = new Page<>(page, rows, count);
                List<FormatLiveRecord> recordList = formatLiveRecordService.list(new QueryWrapper<FormatLiveRecord>().lambda().in(FormatLiveRecord::getId, collect));
                result.setContent(recordList);
                userCollection.setRecordList(result);
            }
            if (type == 2) {
//            新闻
                Page<List<JdNews>> result = new Page<>(page, rows, count);
                List<JdNews> newsList = newsService.list(new QueryWrapper<JdNews>().lambda().in(JdNews::getId, collect));
                result.setContent(newsList);
                userCollection.setNewsList(result);
            }
        } else {
            if (type == 1) {
//            回放
                Page<List<FormatLiveRecord>> result = new Page<>(page, rows, count);
                List<FormatLiveRecord> recordList = new ArrayList<>();
                result.setContent(recordList);
                userCollection.setRecordList(result);
            }
            if (type == 2) {
//            新闻
                Page<List<JdNews>> result = new Page<>(page, rows, count);
                List<JdNews> newsList = new ArrayList<>();
                result.setContent(newsList);
                userCollection.setNewsList(result);
            }
        }
        return Success.success(userCollection);
    }

    @Login
    @GetMapping("/myRelations")
    @ApiOperation("我的关注列表")
    @ApiOperationSupport(order = 5)
    @ApiImplicitParams({
            @ApiImplicitParam(value = "用户角色 1主播 2参赛员", name = "type", dataType = "string", required = true),
            @ApiImplicitParam(value = "页数", name = "page", dataType = "integer", required = true),
            @ApiImplicitParam(value = "页码", name = "rows", dataType = "integer", required = true)
    })
    public Success<Page<List<UserRelation>>> myRelations(
            @ApiIgnore @LoginUser JdAppUser user,
            @RequestParam(defaultValue = "1") Integer type,
            @RequestParam(defaultValue = "1") Integer page,
            @RequestParam(defaultValue = "10") Integer rows
    ) {
        LambdaQueryChainWrapper<JdUserRelation> eq = userRelationService.lambdaQuery()
                .eq(JdUserRelation::getSourceUser, user.getId())
                .eq(JdUserRelation::getRole, type);
        int total = eq.count();
        List<UserRelation> userRelations = userRelationService.relationList(eq, 1);
        final Page<List<UserRelation>> result = new Page<>(page, rows, total);
        result.setContent(userRelations);
        return Success.success(result);
    }

    @Login
    @PostMapping("/myFans")
    @ApiOperation("我的粉丝列表")
    @ApiOperationSupport(order = 6)
    @ApiImplicitParams({
            @ApiImplicitParam(value = "页数", name = "page", dataType = "integer", required = true),
            @ApiImplicitParam(value = "页码", name = "rows", dataType = "integer", required = true)
    })
    public Success<Page<List<UserRelation>>> myFans(
            @ApiIgnore @LoginUser JdAppUser user,
            @RequestParam(defaultValue = "1") Integer page,
            @RequestParam(defaultValue = "10") Integer rows
    ) {
//         1主播 2参赛员
        final Integer total = userRelationService.getFansCount(Integer.valueOf(user.getId()));
        LambdaQueryChainWrapper<JdUserRelation> eq = userRelationService.lambdaQuery()
                .eq(JdUserRelation::getRelationUser, user.getId())
                .groupBy(JdUserRelation::getSourceUser);
        List<UserRelation> userRelations = userRelationService.relationList(eq, 2);
        final Page<List<UserRelation>> result = new Page<>(page, rows, total);
        result.setContent(userRelations);
        return Success.success(result);
    }

    @Login
    @PostMapping("/userFeedback")
    @ApiOperation("用户反馈")
    @ApiOperationSupport(order = 7)
    @ApiImplicitParams({
            @ApiImplicitParam(value = "手机号", name = "mobile", dataType = "string", required = true),
            @ApiImplicitParam(value = "反馈内容", name = "content", dataType = "string", required = true),
            @ApiImplicitParam(value = "图片", name = "image", dataType = "string", required = true)
    })
    public Success<String> userFeedback(
            String mobile, String content, String image,
            @ApiIgnore @LoginUser JdAppUser user
    ) {
        Integer success = userRelationService.userFeedback(mobile, content, image, Integer.valueOf(user.getId()));
        return success > 0 ? Success.success() : Success.error();
    }

    @Login
    @PostMapping("/isRelation")
    @ApiOperation("是否关注 1是2不是")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "关注用户", name = "targetUser", dataType = "integer", required = true),
    })
    public Success<String> isRelation(
            @ApiIgnore @LoginUser JdAppUser user,
            Integer targetUser
    ) {
        Integer flag = userRelationService.isRelation(Integer.valueOf(user.getId()), targetUser);
        return Success.success(flag + "");
    }

    @Login
    @PostMapping("/relation")
    @ApiOperation("关注/取消关注 指定用户")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "关注用户", name = "targetUser", dataType = "integer", required = true),
            @ApiImplicitParam(value = "关注角色身份 1主播2参赛员", name = "role", dataType = "integer", required = true),
    })
    public Success<Integer> relation(
            @ApiIgnore @LoginUser JdAppUser user,
            Integer targetUser, Integer role
    ) {
        JdUserRelation one = userRelationService.lambdaQuery()
                .eq(JdUserRelation::getRelationUser, targetUser)
                .eq(JdUserRelation::getSourceUser, user.getId())
                .eq(JdUserRelation::getRole, role)
                .one();
        if (targetUser.equals(user.getId())) {
            return Success.error("不能关注自己");
        }
        if (one == null) {
            one = new JdUserRelation();
            one.setRelationUser(targetUser);
            one.setSourceUser(Integer.valueOf(user.getId()));
            one.setCt(DateUtils.getToday());
            one.setRole(role);
            userRelationService.save(one);
            return Success.success("已关注", 1);
        } else {
            userRelationService.delete(one.getId());
            return Success.success("已取关", 2);
        }
    }

    @Login
    @GetMapping("/myInvite")
    @ApiOperation("我的邀请好友")
    @ApiOperationSupport(order = 1)
    public Success<List<ViewInviteUser>> myInvite(
            @ApiIgnore @LoginUser JdAppUser user
    ) {
        final List<ViewInviteUser> list = viewInviteUserService.lambdaQuery()
                .eq(ViewInviteUser::getSendUser, user.getId())
                .list();
        return Success.success(list);
    }

    @PostMapping("/getInviteCode")
    @ApiOperation("分享获取邀请码-h5")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "用户id", name = "userId", dataType = "string", required = true),
    })
    public Success<String> getInviteCode(
            Integer userId, String key
    ) {
        final JdUserInvite one = userInviteService.lambdaQuery()
                .eq(JdUserInvite::getSendUser, userId)
                .eq(JdUserInvite::getH5Key, key)
                .last(" limit 1 ")
                .one();
        return Success.success(one.getInviteCode());
    }

    @Login
    @PostMapping("/getInviteUrl")
    @ApiOperation("分享-获取邀请码链接")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "用户id", name = "userId", dataType = "string", required = true),
    })
    public Success<String> getInviteUrl(
            @ApiIgnore @LoginUser JdAppUser user
    ) {
        final String inviteCode = StringUtil.getUuid().substring(0, 6);
        final Date now = Calendar.getInstance().getTime();
        JdUserInvite one = userInviteService.lambdaQuery().eq(JdUserInvite::getSendUser, user.getId()).last(" limit 1").one();
        if (one == null) {
            one = new JdUserInvite();
            one.setInviteCode(inviteCode);
            one.setSendUser(Integer.valueOf(user.getId()));
            one.setCt(now);
            final String key = (now.getTime() / 1000) + "";
            one.setH5Key(key);
            userInviteService.save(one);
        }
        return Success.success(DomainConfig.LOCALHOST + "/share/share.html" + "?u=" + user.getId() + "&key=" + one.getH5Key());
    }

    @Login
    @GetMapping("/myMatch")
    @ApiOperation("我的赛事")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "当前页", name = "page", dataType = "int", required = true),
            @ApiImplicitParam(value = "条数", name = "rows", dataType = "int", required = true),
            @ApiImplicitParam(value = "不传全部 1审核通过2拒绝3待参赛4已参赛", name = "state", dataType = "int", required = true),
    })
    public Success<Page<List<MyMatch>>> myMatch(
            @ApiIgnore @LoginUser JdAppUser user, Integer state,
            @RequestParam(defaultValue = "1") Integer page,
            @RequestParam(defaultValue = "10") Integer rows
    ) {
        final LambdaQueryChainWrapper<MyMatch> eq = matchService.lambdaQuery().eq(MyMatch::getUserId, user.getId());
        if (state != null) {
            if (state < 3) {
                eq.eq(MyMatch::getState, state);
            }
            if (state == 3) {
                eq.eq(MyMatch::getIsConcat, 2);
            }
            if (state == 4) {
                eq.eq(MyMatch::getIsConcat, 1);
            }
        }
        final Integer count = eq.count();
        eq.orderByDesc(MyMatch::getCt);
        eq.orderByDesc(MyMatch::getStartTime);
        final Page<List<MyMatch>> result = new Page<>(page, rows, count);
        final List<MyMatch> list = eq.last(result.convertPage()).list();
        result.setContent(list);
        return Success.success(result);
    }

    @RequestMapping("/myMatchInfo")
    @ApiOperation("我的赛事详情")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "主键id", name = "id", dataType = "int", required = true),
    })
    public Success<MyMatchVo> myMatchInfo(
            Integer id
    ) {
        final MyMatch one = matchService.lambdaQuery().eq(MyMatch::getId, id)
                .last(" limit 1")
                .one();
        if (one == null) {
            return Success.error();
        }
        final MyMatchVo matchVo = new MyMatchVo();
        matchVo.setMatch(one);
        final JdMatchFormatMember formatMember = matchFormatMemberService.lambdaQuery()
                .eq(JdMatchFormatMember::getFormatId, one.getFormatId())
                .eq(JdMatchFormatMember::getUserId, one.getUserId())
                .one();
        if (formatMember != null) {
            matchVo.setScore(formatMember.getScore());
            matchVo.setRank(formatMember.getRank());
            matchVo.setPromotionState(formatMember.getPromotionState());
        }
        //参赛范围
        if ("1".equals(one.getMatchGroup())) {
            one.setMatchGroup("单人");
        } else {
            one.setMatchGroup("团体");
        }
        if (StringUtils.isNotBlank(one.getOrderNum())) {
            final JdOrder order = orderService.lambdaQuery().eq(JdOrder::getOrderNum, one.getOrderNum()).one();
            matchVo.setOrder(order);
        }
        final List<ViewMatchScoreRecord> scoreRecordList = viewMatchScoreRecordService.lambdaQuery()
                .eq(ViewMatchScoreRecord::getUserId, one.getUserId())
                .eq(ViewMatchScoreRecord::getFormatId, one.getFormatId())
                .list();
        matchVo.setScoreRecordList(scoreRecordList);
        return Success.success(matchVo);
    }

    @Login
    @GetMapping("/myMatchLiveRecord")
    @ApiOperation("已分配直播间")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "当前页", name = "page", dataType = "int", required = true),
            @ApiImplicitParam(value = "条数", name = "rows", dataType = "int", required = true),
    })
    public Success<Page<List<FormatLiveRecord>>> myMatchLiveRecord(
            @RequestParam(defaultValue = "1") Integer page,
            @RequestParam(defaultValue = "10") Integer rows,
            @ApiIgnore @LoginUser JdAppUser user
    ) {
        final LambdaQueryChainWrapper<JdMatchLiveUser> eq = matchLiveUserService.lambdaQuery()
                .eq(JdMatchLiveUser::getUserId, user.getId());
        final Integer total = eq.count();
        final Page<List<FormatLiveRecord>> result = new Page<>(page, rows, total);
        final List<JdMatchLiveUser> list = eq.orderByDesc(JdMatchLiveUser::getLiveRecordId).last(result.convertPage()).list();
        final List<Integer> collect = list.stream().map(JdMatchLiveUser::getLiveRecordId).collect(Collectors.toList());
        final List<FormatLiveRecord> recordList = formatLiveRecordService.lambdaQuery().in(FormatLiveRecord::getId, collect).list();
        result.setContent(recordList);
        return Success.success(result);
    }

}
